﻿using System;
namespace TaskHub.EntityDataModel
{
    public class TaskEDM
    {
        public int TaskID { get; set; }
        public int OwnerAccountId { get; set; }
        public int TargetAccountId { get; set; }
        public string Description { get; set; }
        public string ObservationText { get; set; }
        public DateTime DueDate { get; set; }
        public TaskStatus Status { get; set; }

        public enum TaskStatus {
            Aguardando,
            Aceito,
            Recusado,
            Concluido
        }


        public TaskEDM() { }

        public TaskEDM(int OwnerAccountId,
                       int TargetAccountId,
                       string Description,
                       string ObservationText,
                       DateTime DueDate,
                       char Status)
        {
            Random r = new Random(DateTime.Now.Millisecond);
            this.TaskID = r.Next(1, int.MaxValue);
            this.OwnerAccountId = OwnerAccountId;
            this.TargetAccountId = TargetAccountId;
            this.Description = Description;
            this.ObservationText = ObservationText;
            this.DueDate = DueDate;            

            switch (Status)
            {
                case '0':
                    this.Status = TaskStatus.Aguardando;
                    break;
                case 'A':
                    this.Status = TaskStatus.Aceito;
                    break;
                case 'R':
                    this.Status = TaskStatus.Recusado;
                    break;
                case 'C':
                    this.Status = TaskStatus.Concluido;
                    break;
                default:
                    this.Status = TaskStatus.Aguardando;
                    break;
            }
        }
    }
}
